package com.napenalki.toto.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class GroupValidator implements ConstraintValidator<Group, String> {

    
    @Override
    public void initialize(Group constraintAnnotation) {
        //
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        
        if (value == null) {
            return false;
        }
        
        if (value.length() != 1) {
            return false;
        }
        
        char group = value.toUpperCase().charAt(0);
        
        return group >= 'A' && group <= 'H';
    }

}
